﻿using UnityEngine;
using System.Collections;
using DICE_GS;

public class BuffIcon : MonoBehaviour {

	public bool isActive;
	public AbnormalType abType;
	public int abnormalParam;
	public int index;
	public UISprite sprite;

	void Awake()
	{
		isActive=true;
		sprite = GetComponent<UISprite>();
	}

	public void Activate(AbnormalType abnormalType, int _abnormalParam, int listActiveCount, string iconName)
	{
		index = listActiveCount;
		isActive=true;
		abType = abnormalType;
		abnormalParam = _abnormalParam;
		gameObject.SetActive(true);
		SetPosition();
		sprite.spriteName = iconName;
	}

	public void GotoPool()
	{
		isActive=false;
		abType = AbnormalType.NONE;
		abnormalParam = 0;
		index = -1;
		gameObject.SetActive(false);
	}

	public void SetPosition()
	{
		transform.localPosition = new Vector3( 0, -index*40, 0);
		if(index>1)
			gameObject.SetActive(false);
		else
			gameObject.SetActive(true);
	}

	public void Init(AbnormalType abnormalType, int _abnormalParam, int listActiveCount, string iconName)
	{
		abType = abnormalType;
		abnormalParam = _abnormalParam;
		index = listActiveCount;
		SetPosition();
		sprite.spriteName = iconName;
	}

	public bool IsSameAbnormal(AbnormalType abnormalType, int _abnormalParam)
	{
		if(abType==abnormalType && _abnormalParam==abnormalParam)
			return true;
		return false;
	}
}
